package com.ticket.sass.admin.controller;

import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.ticket.sass.admin.business.AreaBusiness;
import com.ticket.sass.admin.business.impl.AreaBusinessImpl;
import com.ticket.sass.admin.dto.input.areas.AreaListInput;
import com.ticket.sass.admin.dto.output.area.AreaListOutput;
import com.ticket.sass.admin.model.PageModel;
import com.ticket.sass.admin.model.ResultModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author ywb
 * @date 2022-09-27 14:49
 */
@RestController
@Api(tags = {"区域-模块"})
@ApiSupport(order = 3)
@RequestMapping("/areas")
public class AreaController {
    
    final AreaBusiness business;
    
    public AreaController(AreaBusinessImpl business) {
        this.business = business;
    }
    
    @GetMapping
    @ApiOperation("列表")
    public ResultModel<PageModel<AreaListOutput>> list(
        @Valid AreaListInput input
    ) {
        return ResultModel.success(
            business.list(input.getParentCode())
        );
    }
}
